<template>
  <div class="campus-box">
    <div class="search-box">
      <el-button type="primary" @click="goCreateCampus">新建校区</el-button>
      <div class="search-item">
        <el-input v-model="keyCampusName" placeholder="请输入校区名称" style="width:200px;" />
        <el-button type="primary">搜索</el-button>
      </div>
    </div>
    <el-table :data="campusTableData" border style="width: 100%;">
      <el-table-column prop="campusName" label="班级名称" align="center"/>
      <el-table-column label="校区地址" align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.territory.join('') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="详细地址" align="center" min-width="150">
        <template slot-scope="scope">
          <span>{{ scope.row.territory.join('')+scope.row.address }}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button type="text" @click="goCreateCampus($event,scope.row.id)">编辑</el-button>
          <el-button type="text">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  data() {
    return {
      keyCampusName: '',
      campusTableData: [
        {
          id: '1',
          campusName: '校区本部',
          territory: ['北京市', '市辖区', '海淀区'],
          address: '燕园街道北京大学',
        }
      ],
    }
  },
  methods: {
    goCreateCampus(e, id) {
      // 新建课程不传递id，跳转页面课更换所属课程、
      // 编辑跳转传递id，跳转页面不可更换课程
      this.$router.push({ name: 'Createcampus', query: { 'campusId': id } })
    }
  }
}
</script>

<style lang="scss" scoped>
.campus-box {
  padding: 20px;
  .search-box {
    margin-bottom: 20px;
    .search-item {
      float: right;
    }
  }
  .class-title {
    box-sizing: border-box;
    width: 100%;
    height: 100px;
    margin-bottom: 24px;
    padding: 20px 24px;
    background: #f5f7fa;
    .title {
      margin-bottom: 10px;
      color: #353535;
      font-weight: 700;
      font-size: 20px;
    }
    .tip {
      display: inline-block;
      margin-right: 30px;
      font-size: 14px;
      line-height: 22px;
      .label {
        margin-right: 20px;
        color: #888;
      }
      .content {
        color: #353535;
      }
    }
  }
}
</style>
